//
//  HTTPInterface.h
//  YLNetworkingFrame
//
//  Created by Topsun on 16/6/3.
//  Copyright © 2016年 tcl. All rights reserved.
//

#ifndef HTTPInterface_h
#define HTTPInterface_h

@protocol HttpInterface;
@protocol HttpAsynInterface;


typedef id<HttpInterface> HttpInterface;
typedef id<HttpAsynInterface> HttpAsynInterface;

typedef void(^CompletionRequest)(id resultSource);

//  Http协议处理接口
@protocol HttpInterface <NSObject>

@property (nonatomic, strong  ) NSURL    *url;// 设置URL
@property (nonatomic, strong  ) NSError  *error;// 当前错误信息
@property (nonatomic, strong  ) NSObject *userInfo;// 用户自定义数据
@property (nonatomic, readonly) NSString *responseString;// 网络字符
@property (nonatomic, readonly) NSData   *responseData;// 网络二进制数据
@property (nonatomic, strong  ) NSString *requestMethod;// 请求方式

// 获取返回的响应的字符串
- (NSString*) responseString;

// 添加一个Post请求参数
- (void)addPostValue:(id<NSObject>)value forKey:(NSString *)key;

// 添加一个Post请求参数，如果存在则将之前设置的值清楚
- (void)setPostValue:(id<NSObject>)value forKey:(NSString *)key;

// 添加一个Get请求参数
- (void)addGetValue:(id<NSObject>)value forKey:(NSString *)key;

// 添加一个Get请求参数，如果存在则将之前设置的值清楚
- (void)setGetValue:(id<NSObject>)value forKey:(NSString *)key;

// 添加一个head请求参数
- (void)addHeadValue:(id<NSObject>)value forKey:(NSString *)key;

// 添加一个Head请求参数，如果存在则将之前设置的值清楚
- (void)setHeadValue:(id<NSObject>)value forKey:(NSString *)key;

@end

// Http协议的异步处理接口
@protocol HttpAsynInterface <HttpInterface>

// 启动一个异步请求
- (void) startAsynchronous:(CompletionRequest)block;

@end

#endif /* HTTPInterface_h */
